package com.mingweicai.intergration.test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;

public class Main {

  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    String nextLine = scanner.nextLine();

    char ch = scanner.nextLine().charAt(0);

    char chs[]  = nextLine.toCharArray();

    int count = 0;
    for(char c: chs){
      if(c >= 'a' && c<= 'z'){
        if(ch == c || ch == c - 32){
          count ++;
        }
      }
      if(c >= 'A' && c<= 'Z'){
        if(ch == c || ch == c + 32){
          count ++;
        }
      }
    }

    System.out.println(count);

  }

  public static List<String> letterCombinations(String digits) {

    Map<Integer,String> map = new HashMap();
    map.put(2, "abc");
    map.put(3, "def");
    map.put(4, "ghi");
    map.put(5, "jkl");
    map.put(6, "mno");
    map.put(7, "pqrs");
    map.put(8, "tuv");
    map.put(9, "wxyz");

    int length = digits.length();
    List<String> res = new ArrayList();
    List<String> strs = new ArrayList();
    for(int i=0; i<digits.length(); i++){
      int index = Integer.valueOf(digits.substring(i, i+1));
      strs.add(map.get(index));
    }
    System.out.println(strs);
    StringBuilder builder = new StringBuilder();
    dfs(res,strs,0,builder,length);
    return res;
  }

  public static void dfs(List<String> res, List<String> strs, int index, StringBuilder builder, int n){
    if(index >= n){
      res.add(builder.toString());
      return;
    }
    String str = strs.get(index);
    for(int i=0; i<str.length(); i++){
      String c = str.substring(i, i+1);
      builder.append(c);
      dfs(res,strs,index+1, builder,n);
      builder.deleteCharAt(index);
    }
  }

}
